package easy;

public class Solution_747 {

    public int dominantIndex(int[] nums) {
        int maxIndex = 0, max = -1;
        for (int i = 0; i < nums.length; i++) {
            if (max < nums[i]) {
                maxIndex = i;
                max = nums[i];
            }
        }
        for (int num : nums) {
            if (num != max && num<<1 > max) {
                return -1;
            }
        }
        return maxIndex;
    }

    public static void main(String[] args) {
        Solution_747 model = new Solution_747();
        System.out.println(model.dominantIndex(new int[]{3, 6, 1, 0}));
        System.out.println(model.dominantIndex(new int[]{1, 2, 3, 4}));
        System.out.println(model.dominantIndex(new int[]{0,0,3,2}));
    }
}
